<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=">
<title>后台管理系统</title>
<link rel="stylesheet" href="__PUBLIC__/Admin/css/css.css">
<script src="__PUBLIC__/Admin/js/jquery-1.9.1.js"></script>
<script src="__PUBLIC__/Common/Layer/layer.js"></script>
<script src="__PUBLIC__/Common/Layer/extend/layer.ext.js"></script>
<script src="__PUBLIC__/Common/My97Date/WdatePicker.js"></script>

<script>
//查看详情
	function look_detail(id){
		parent.layer.open({
			type: 2,
			title: '订单',
			shadeClose: true,
			shade: 0.5,
			maxmin: true,
			area: ['80%', '90%'],
			content: "{:U('Goods/order_lst_detail')}?id="+id //iframe的url
		});
	}
	function refresh(){
		window.location.href="{:U('Goods/orders_list')}"
	}

//删除用户
function del(id){
	$("#del"+id+" td").css('background','#CBDFF2');
	parent.layer.confirm('真的要删除吗？', {
		btn: ['确认','取消'], //按钮
		shade: 0.5 //显示遮罩
	}, function(){
		$.post("{:U('Goods/goods_orders_del')}", { "id": id},function(data){
			if(data == 1){
				parent.layer.msg('删除成功', { icon: 1, time: 1000 }, function(){
						$("#del"+id).remove();
					});
			}else{
				parent.layer.msg('删除失败', {icon: 2, time: 2000 }); 
			}
		}, "json");
	},function(){
		$("#del"+id+" td").css('border-top','0');
		$("#del"+id+" td").css('border-bottom','1px solid #EFEFEF');
	});
}
</script>
</head>
<body>
<style>
	.tr_content {
		line-height: 32px;
		height:32px;
		font-size: 14px;
	}
	
	.layui-layer-title{
		font-weight:bold;
	}
</style>
<div class="nav">
	<div class="nav_title">
    	<h4><img class="nav_img" src="__PUBLIC__/Admin/img/tab.gif" /><span class="nav_a">用户管理 - 商城订单列表</span></h4>
    </div>
</div>

<form action="__SELF__" method="get">
	<div class="search" style=" line-height:50px; padding-left:30px; margin-top:3px;">
		订单编号：<input type="text" class="input" name="orders_num" value="{$_GET['orders_num']}" maxlength="30" size="20" />
		  &nbsp;&nbsp;
		 手机号： <input type="text" class="input" name="mobile" value="{$_GET['mobile']}" maxlength="30" size="20" />
		 &nbsp;&nbsp;
		  
         开始日期：<input type="text" class="input" name="begin_date" value="{$_GET['begin_date']}" onClick="WdatePicker()"/>
         结束日期：<input type="text" class="input" name="end_date" value="{$_GET['end_date']}" onClick="WdatePicker()"/>
         <br/>
		支付状态：<select name="pay_status" style="height:30px; text-align: center">
			<option value="{$pay_status}"><if condition="$pay_status == -1">待支付<else/>已支付</if></option>
			<option value="">----------------------</option>
			<option value="1">已支付</option>
			<option value="-1">待支付</option>
		 </select>&nbsp;&nbsp;
		 订单状态： 
		 <select name="orders_status" style="height:30px; text-align: center">
		 	<option value="{$_GET['orders_status']}">
		 		<if condition="$_GET['orders_status'] == 2">已发货</if>
		 		<if condition="$_GET['orders_status'] == 3">已收货,待完成</if>
		 		<if condition="$_GET['orders_status'] == 4">已申请退货</if>
		 		
		 		<if condition="$_GET['orders_status'] == 5">已完成</if>
		 		<if condition="$_GET['orders_status'] == 6">已允许退货</if>

		 	</option>
			<option value="">----------------------</option>
			<option value="2">已发货</option>
			<option value="3">已收货,待完成</option>
			
			<option value="4">已申请退货</option>
			<option value="5">已完成</option>
			<option value="6">已允许退货</option>

			

		 </select>&nbsp;&nbsp;
		 姓名： <input type="text" class="input" name="realname" value="{$_GET['realname']}" maxlength="30" size="20" />
		 &nbsp;&nbsp;
		<button type="submit" class="button">查 询</button>
		<button type="button" class="button" onclick="refresh();">刷 新</button>
		<button type="button" class="button" onClick="export_orders();" style="background:#146AC1;">批量导出订单Excel</button>
	</div>
</form>

<div class="list">
	  <table width="100%" border="0" cellpadding="0" cellspacing="0" class="list_table">
      <thead>
	    <tr>
	      <td width="9%"><div align="center">ID</div></td>

	      <td width="14%"><div align="center">订单编号</div></td>

	      <td width="13%"><div align="center">收货人&amp;手机</div></td>
	      <td width="10%"><div align="center">快递&amp;单号</div></td>

	      <td width="15%"><div align="center">订单状态</div></td>
	      <td width="12%"><div align="center">下单时间</div></td>
	      <td width="14%"><div align="center">发货</div></td>
		  <td width="13%"><div align="center">操作</div></td>

        </tr>
        
        </thead>
        <tbody>
        <foreach name="res" item="vo">
	  		<tr id="del{$vo.id}" class="tr_content" onmouseover="$(this).css('color','red')" onmouseleave="$(this).css('color','#555')">
	  		  <td width="9%" style="height: 40px"><div align="center">{$vo.id}</div></td>
			

				<td width="14%"><div align="center">{$vo.orders_num}</div></td>

				<td><div align="center">{$vo.realname}<br/>{$vo.mobile}</div></td>
				<td><div align="center">{$vo.kuaidi_name}<br/>{$vo.kuaidi_num}</div></td>

				<td width="15%">
				   <div align="center">


			              <if condition="$vo['pay_status'] eq 0">
			                  待付款
			              </if>


			              <if condition="$vo['pay_status'] eq 1 && $vo['orders_status'] eq 0">
			                  待发货
			              </if>

			              <if condition="$vo['orders_status'] egt 2">
			                  <if condition="!empty($vo['fahuo_time'])">
			                  已发货
			                  </if>
			              </if>

			              <if condition="$vo['orders_status'] eq 3">
			                  已签收
			              </if>

			              <if condition="$vo['orders_status'] eq 4">
			                  已申请退货
			              </if>

			              <if condition="$vo['orders_status'] eq 5">
			                  已完成
			              </if>




				  </div>
				</td>
				<td width="12%"><div align="center">{$vo.create_time|date='Y-m-d H:i:s',###}</div></td>
				<td width="14%">
				<div align="center">
					<if condition="$vo.kuaidi_num eq ''">
						<if condition="$vo['pay_status'] == 1 && $vo['orders_status'] != 4">
							<button class="button" onclick="add({$vo.id})" style=" border-radius:5px; background:#555;">发货</button>
						</if>
					<else/>
					<button class="button" style=" border-radius:5px;" onclick="show_info({$vo.kuaidi_num})">
					快递查询</button>
						<if condition="$vo['orders_status'] != 4 and $vo['orders_status'] != 5">
							<button class="button" onclick="done({$vo.id})" style=" border-radius:5px; background:#555;">确认完成</button>
						</if>

					</if>
					
					<if condition="$vo.orders_status == 4 && $vo.tuihuo_chuli_status == 0">
					<div style="margin-top:5px;">
<button class="button" style=" border-radius:5px;" onclick="tuihuo_ok({$vo.id},1);">允许退货</button>
<button class="button" style=" border-radius:5px;" onclick="tuihuo_no({$vo.id},-1);">拒绝</button>
					</if>

					<if condition="!empty($vo['tuihuo_chuli_time'])">
					<br/> {$vo.tuihuo_chuli_time|date='Y-m-d H:i:s',###}   <br/>
					</if>

					<if condition="$vo.tuihuo_chuli_status == 1">
					已允许退货
					</if>
					
					<if condition="$vo.tuihuo_chuli_status == -1">
					已拒绝退货
					</if>
					</div>
				</div>
				</td>
				<td width="13%">
				<div align="center">

				<a href="javascript:void (0);" style=" background-color: #146AC1; padding: 8px; border-radius: 4px; color: #ffffff" onclick="look_detail({$vo.id})">详情</a>
				<!-- <a class="a_button" href="javascript:;" onclick="del({$vo[id]})">删除</a> -->
				</div>
				</td>
			</tr>

        </foreach>
        </tbody>
<script>
function tuihuo_ok(id){
	parent.layer.confirm('确认允许退货吗?', {
	  btn: ['确认','取消'] //按钮
	}, function(){
		parent.layer.closeAll();
	  	parent.iframe.window.location.href="{:U('Goods/tuihuo_chuli')}?orders_id="+id+"&status=1";
	});
}
function tuihuo_no(id){
	parent.layer.confirm('确认拒绝退货吗?', {
	  btn: ['确认','取消'] //按钮
	}, function(){
		parent.layer.closeAll();
	  	parent.iframe.window.location.href="{:U('Goods/tuihuo_chuli')}?orders_id="+id+"&status=-1";
	});
}
</script>        

<script>
function add(a){
	parent.layer.open({
		type: 2,
		shadeClose: true,
		shade: 0.5,
		area: ['450px', '250px'],
		title: '添加发货信息',
		content: '{:U("Goods/kuaidi_add")}?id='+a,
	});
}

function done(id){	
	//prompt层
	var index=layer.prompt({
	  title: '输入操作密码，并确认',
	  formType: 1 //prompt风格，支持0-2
	}, function(pass){
	$(".layui-layer-btn0").attr("disabled","disabled");
	$(".layui-layer-btn0").text("提交中...");
	  $.post("{:U('Goods/done')}",{
					   'order_id':id,
					   'password':pass
					},function(data){
						if(data==1){
							layer.close(index);
							layer.msg('已经成功标记为确认收货', {
								  icon: 1,
								  time: 2000 //2秒关闭（如果不配置，默认是3秒）
								}, function(){
									window.location.href="__SELF__";
								});
						}else if(data==2){
							layer.close(index); 
							layer.msg('密码错误');
						}else{
							layer.close(index);
							layer.msg('标记出错');
						}
					})
	});	
}

function show_info(num){
		parent.layer.open({
			type: 2,
			shadeClose: true,
			shade: 0.2,
			area: ['800px', '480px'],
			title: '查询快递单号',
			content: 'http://www.zzumall.com/kuaidi/index.php?num='+num,
		});
	}
</script>
  </table>
</div>

<!-- 分页 -->
<div class="page">
{$page}
</div>


</body>
</html>
